home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / tkAppInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-18  |  5.5 KB  |  137 lines

  1. /* 
  2.  * tkAppInit.c --
  3.  *
  4.  *    Provides a default version of the Tcl_AppInit procedure for
  5.  *    use in wish and similar Tk-based applications.
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * All rights reserved.
  9.  *
  10.  * Permission is hereby granted, without written agreement and without
  11.  * license or royalty fees, to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose, provided that the
  13.  * above copyright notice and the following two paragraphs appear in
  14.  * all copies of this software.
  15.  * 
  16.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20.  *
  21.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26.  */
  27.  
  28. #ifndef lint
  29. static char sccsid[] = "@(#) tkAppInit.c 1.17 95/09/08 17:05:44";
  30. #endif /* not lint */
  31.  
  32. #include "tk.h"
  33.  
  34. /*
  35.  * The following variable is a special hack that allows applications
  36.  * to be linked using the procedure "main" from the Tk library.  The
  37.  * variable generates a reference to "main", which causes main to
  38.  * be brought in from the library (and all of Tk and Tcl with it).
  39.  */
  40.  
  41. extern int main();
  42. int *tclDummyMainPtr = (int *) main;
  43.  
  44. /*                                                                             
  45.  *----------------------------------------------------------------------       
  46.  *                                                                             
  47.  * main --                                                                     
  48.  *                                                                             
  49.  *      This is the main program for the application.                          
  50.  *                                                                             
  51.  * Results:                                                                    
  52.  *      None: Tk_Main never returns here, so this procedure never              
  53.  *      returns either.                                                        
  54.  *                                                                             
  55.  * Side effects:                                                               
  56.  *      Whatever the application does.                                         
  57.  *                                                                             
  58.  *----------------------------------------------------------------------       
  59.  */                                                                            
  60. int                                                                            
  61. main(argc, argv)                                                               
  62.     int argc;                   /* Number of command-line arguments. */        
  63.     char **argv;                /* Values of command-line arguments. */        
  64. {                                                                              
  65.     Tk_Main(argc, argv, Tcl_AppInit);
  66.     return 0;                   /* Needed only to prevent compiler warning. */ 
  67. }                                                                              
  68.                                                                              
  69. /*                                                                             
  70.  *----------------------------------------------------------------------
  71.  *
  72.  * Tcl_AppInit --
  73.  *
  74.  *    This procedure performs application-specific initialization.
  75.  *    Most applications, especially those that incorporate additional
  76.  *    packages, will have their own version of this procedure.
  77.  *
  78.  * Results:
  79.  *    Returns a standard Tcl completion code, and leaves an error
  80.  *    message in interp->result if an error occurs.
  81.  *
  82.  * Side effects:
  83.  *    Depends on the startup script.
  84.  *
  85.  *----------------------------------------------------------------------
  86.  */
  87.  
  88. int
  89. Tcl_AppInit(interp)
  90.     Tcl_Interp *interp;        /* Interpreter for application. */
  91. {
  92.     extern int Blt_Init _ANSI_ARGS_((Tcl_Interp *interp));
  93. #if (TK_MINOR_VERSION == 0)
  94.     Tk_Window main;
  95.     main = Tk_MainWindow(interp);
  96. #endif
  97.  
  98.     /*
  99.      * Call the init procedures for included packages.  Each call should
  100.      * look like this:
  101.      *
  102.      * if (Mod_Init(interp) == TCL_ERROR) {
  103.      *     return TCL_ERROR;
  104.      * }
  105.      *
  106.      * where "Mod" is the name of the module.
  107.      */
  108.     if (Blt_Init(interp) == TCL_ERROR) {
  109.     return TCL_ERROR;
  110.     }
  111.     if (Tcl_Init(interp) == TCL_ERROR) {
  112.     return TCL_ERROR;
  113.     }
  114.     if (Tk_Init(interp) == TCL_ERROR) {
  115.     return TCL_ERROR;
  116.     }
  117.  
  118.     /*
  119.      * Call Tcl_CreateCommand for application-specific commands, if
  120.      * they weren't already created by the init procedures called above.
  121.      */
  122.  
  123.     /*
  124.      * Specify a user-specific startup file to invoke if the application
  125.      * is run interactively.  Typically the startup file is "~/.apprc"
  126.      * where "app" is the name of the application.  If this line is deleted
  127.      * then no user-specific startup file will be run under any conditions.
  128.      */
  129.  
  130. #if (TK_MINOR_VERSION > 0)
  131.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
  132. #else
  133.     tcl_RcFileName = "~/.wishrc";
  134. #endif
  135.     return TCL_OK;
  136. }
  137.